
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2
 * @Author : WangRuoyu 
 * @Date : 2023/5/17 10:18
 */

#include "iostream"

using namespace std;

int main() {
    int n;
    cin >> n;
    int total = 0;

    bool st[n];
    for (int i = 0; i < n; ++i) {
        st[i] = false;
    }

    for (int i = 0; i < n; ++i) {
        int m, init = 0;
        cin >> m >> init;
        int fall = 0;
        for (int j = 0; j < m - 1; ++j) {
            int x;
            cin >> x;
            if (x > 0) {
                if (init + fall != x) {
                    st[i] = true;
                }
                init = x;
                fall = 0;
            } else {
                fall += x;
            }
        }
        total += init + fall;
    }

    int d = 0, e = 0;
    for (int i = 0; i < n; ++i) {
        if (st[i]) {
            d++;
            if (st[(i + n + 1) % n] && st[(i + n - 1) % n]) {
                e++;
            }
        }
    }

    cout << total << " " << d << " " << e;
    return 0;
}